# 导入第三方库（pip可下载）
import matplotlib.pyplot
import numpy

# 导入自定义库
from dapas.statistics import *
from dapas.distribution import *


# 套壳函数（方便换函数）
def f(x):
    y = norm(x)  # 更换这里的函数即可
    # y = exp(x, 5)
    # y = unif(x, -1, 5)
    return y


# 生成数据与概率密度计算
X = numpy.linspace(-10, 10, 100)
Y = []
for x_i in X:
    Y.append(f(x_i))

S = [0.073956013, -1.478974682, 0.525451067, -0.114028297,  0.256886040,
    -1.174617670, -0.956493501, 2.085661463,  0.052694510, -0.256991521,
    0.650168345,  0.603600825,  1.527980415, -0.550144332,  0.567355993,
    0.815406738, -0.683031480, -1.022334470,  0.127504098, -0.541663787,
    0.719038235, -2.949525736,  0.871478774,  0.922059928, -1.128695841,
    0.335999305, -1.199041101, -1.589886774,  0.699591284, -0.138949739,
    -0.594879886,  1.002690315,  1.658214729, -0.087131003, -0.607943489,
    0.799952880,  1.077781123, -0.921951460, -0.217126471,  1.242824533,
    0.663346821, -0.638986607,  0.516635183,  0.604486115,  1.247115965,
    0.690562495,  0.796354125,  2.235336902, -1.112383491,  1.129886193,
    -0.696358094,  0.983617996,  2.275023210, -0.601298014, -0.041139637,
    -0.828766742,  0.736463757,  0.883822200,  0.726672262,  1.511917152,
    1.049928132, -0.121727052,  2.469706356, -0.835849986,  0.862856335,
    -1.300420690,  0.567245854, -0.044945763, -0.304383846,  1.728240296,
    -2.241927243, -1.078943213, -0.876749576,  1.007936943, -0.480290055,
    -0.571731045,  0.303734715, 0.855399203, -0.006173381, -0.752982486,
    -1.498736125, -0.144905533,  0.117025799,  0.615512586,  0.276210378,
    2.990419614,  1.704820838,  1.148798305, -1.030239753,  0.581358511,
    0.092419927, -0.417118631, -0.742440423, -1.337849651,  0.527044970,
    0.496195770,  0.330885858, -1.113945364,  0.562244344,  1.825650886]

Y_s = []


# 绘制图像
matplotlib.pyplot.figure(num=1, figsize=(10, 5))
matplotlib.pyplot.plot(X, Y, color="black", linewidth=1, linestyle="--", label="σ = 0.8")
matplotlib.pyplot.plot(X, Y_s, color="black", linewidth=1, linestyle="--", label="rnorm")


# 显示图例
matplotlib.pyplot.legend(loc="upper right")
# matplotlib.pyplot.legend(handles=[INS_line1, INS_line0, INS_line2, INS_line3, INS_line4], labels=["σ = 0.8", "Standard", "σ = 2", "σ = 4", "σ = 8"])
# handles: 设置显示哪些曲线的图例
# labels(标签): 这里设置的文字将会覆盖绘图中设置的标签文字
# loc(位置): best（系统根据窗口大小以及图线占据的位置自动调整）, upper right, center right, lower right


# 显示绘图结果
matplotlib.pyplot.show()
